package com.yidao.jdbc.test.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/ServletZhuanFaChongDingXiang2")
public class ServletZhuanFaChongDingXiang2 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    /**
     *     http://localhost:8080/ServletZhuanFaChongDingXiang2
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        if (false) {
            request.setAttribute("username","hanks7");
            request.getRequestDispatcher("/getParameter/zhuanFaChongDingXiang2.jsp").forward(request,response);
        }else{
            getServletContext().setAttribute("username","getServletContext");
            //jsp中取值 application.getAttribute("username");
            response.sendRedirect("/getParameter/zhuanFaChongDingXiang2.jsp");
        }

    }
}
